<?php

class Amplop_model extends CI_Model {
	
	private $primary_key = 'ID_AMPLOP';
	private $table_name = 'amplop';
	
	function __construct()
	{
		parent::__construct();
	}
	
	function get_all()
	{
		return $this->db->get($this->table_name);
	}
	function count_all() 
	{
		return $this->db->count_all($this->table_name);
	}
	
	function get_by_id($id)
	{
		$this->db->where($this->primary_key, $id);
		return $this->db->get($this->table_name);
	}
	
	function save($amplop)
	{
		$this->db->insert($this->table_name, $amplop);
		return $this->db->insert_id();
	}
	
	function update($id, $amplop)
	{
		$this->db->where($this->primary_key, $id);
		$this->db->update($this->table_name, $amplop);
	}
	
	function delete($id)
	{
		$this->db->where($this->primary_key, $id);
		$this->db->delete($this->table_name);
	}
}